package Controler.Matiere;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import JDBC.Matiere_Afficher;
import Model.Listes;
import Model.Matiere;

/**
 * Servlet implementation class Professeur_ChargerController
 */
@WebServlet("/Matiere_ChargerController")
public class Matiere_ChargerController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Matiere_ChargerController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		HttpSession session = request.getSession();
		Listes listes = (Listes) session.getAttribute("listes");
		
		if (listes==null)
		{
			listes = new Listes();
		}
		
		Matiere_Afficher listeMat = new Matiere_Afficher();
		ArrayList<Matiere> mesMatieres = listeMat.afficher();
		listes.setMesMatieres(mesMatieres);
		System.out.println(listes.getMesMatieres().size());
		session.setAttribute("listes", listes);
		request.getRequestDispatcher("Vues/Matiere/vueGRP1_tableauMat.jsp").forward(request, response);

		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
